﻿using Gobang.Client.Common;
using Gobang.Client.View.FrmPage;
using Sunny.UI;
using System.Diagnostics;

namespace Gobang.Client.View
{
    public partial class FrmMain : UIHeaderMainFooterFrame
    {
        private readonly MainPage _mainPage;
        public FrmMain()
        {
            this.ShowWaitForm();

            InitializeComponent();

            //设置关联
            //Header.TabControl = MainTabControl;

            //增加页面到Main
            _mainPage = new MainPage(this);
            AddPage(_mainPage, 1);

            this.WindowState = FormWindowState.Normal;

            Thread.Sleep(100);
            this.HideWaitForm();
        }

        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.ShowWaitForm("正在退出，请稍候...");

            NetworkingCenter.Dispose();
            _mainPage.Dispose();
            this.Dispose();
            GC.Collect();
            Application.ExitThread();
            Process.GetCurrentProcess().Kill();

            Thread.Sleep(500);
            this.ShowWaitForm();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Normal;
        }
    }
}
